package com.luoran.system.config;

import javax.mail.MessagingException;

public class TestQqEmail {
    public static void main(String[] args) {
        String fromEmail = "tencetmusician@vip.qq.com"; // 发件人邮箱
        String authCode = "teaekbfumgbdbcca"; // QQ邮箱的授权码（不是密码）
        String toEmail = "2270600785@qq.com"; // 收件人邮箱

        String subject = "Test Email";
        String messageBody = "<h1>This is a test email</h1>";

        // 发送普通邮件
        try {
            QQMailUtils.sendEmail(fromEmail, authCode, toEmail, subject, messageBody, true);
        } catch (MessagingException e) {
            e.printStackTrace();
        }

        // 发送带附件的邮件
        String[] attachments = {"/path/to/file1.txt", "/path/to/file2.jpg"};
        try {
            QQMailUtils.sendEmailWithAttachment(fromEmail, authCode, toEmail, subject, messageBody, true, attachments);
        } catch (MessagingException e) {
            e.printStackTrace();
        }
    }
}
